#include "datagramthread.h"
#include <QThread>

DatagramThread::DatagramThread(QObject *parent)
    : QObject{parent}
{
    m_bisConnect = false;
    m_UdpSocket = new QUdpSocket(this);
}

void DatagramThread::ReceiverDatagram(const QHostAddress &ipAddress,const quint16 &port)
 {
     while(m_bisConnect == true)
     {
        //qDebug() << ipAddress << port;
        QThread::msleep(3);
        QDateTime curDateTime = QDateTime::currentDateTime();
        m_UdpSocket->writeDatagram(curDateTime.toString().toLocal8Bit(),ipAddress,port);
        if(m_bisConnect == false)
        {
            break;
        }
     }
}

void DatagramThread::setConnStatus(bool flag)
{
    m_bisConnect = flag;
}
